var DOM = {

	byId: function (node) {
        return typeof node == 'string' ? document.getElementById(node) : node
	},

	firstChild: function (p, tag)
	{
		var out = p.firstChild;
		while(out && out.tagName != tag)
		{
			out = out.nextSibling;
		}
		return out;
	},

	lastChild: function (p, tag)
	{
		var out = p.lastChild;
		while(out && out.tagName != tag)
		{
			out = out.previousSibling;
		}
		return out;
	},

	next: function (o, tag)
	{
		var out = o;
		do
		{
			out = out.nextSibling;
		}
		while(out && out.tagName != tag)
		return out;
	},

	prev: function (o, tag)
	{
		var out = o;
		do
		{
			out = out.previousSibling;
		}
		while(out && out.tagName != tag)
		return out;
	},

	insertAfter: function(parent, node, referenceNode)
	{
	    parent.insertBefore(node, referenceNode.nextSibling);
	}

}